package com.example.demos.service.impl;

import com.example.demos.dao.H2Dao;
import com.example.demos.model.User;
import com.example.demos.service.H2Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * h2 service.
 *
 * @author liucheng
 * @since 0.1 2021-06-06 8:44 PM
 **/
@Service
public class H2ServiceImpl implements H2Service {
    private H2Dao h2Dao;

    public H2ServiceImpl(H2Dao h2Dao) {
        this.h2Dao = h2Dao;
    }

    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    @Override
    public void addUser() {
        var user = new User();
        user.setName("cc");
        user.setPhone("cc-123456");
        h2Dao.save(user);

        if (true) {
            throw new RuntimeException("xxxxx");
        }
    }
}
